var xlsx = require('node-xlsx')
var fs = require('fs')
var sheets = xlsx.parse('charpter1.xlsx')
var sheet = sheets[0].data
var fs = require('fs')
var json_data = []
for (var rowId = 1; rowId < sheet.length; rowId++) {
    let data = {}
    var row = sheet[rowId]
    data.type = row[0]
    data.title = row[1]
    data.option = row[2].split("\r\n");
    data.answer = row[3]
    data.explain = row[4]
    data.level = row[5]
    json_data.push(data)
}
var json_str = JSON.stringify(json_data)
var result = json_str.replace(/},/g, '}\n').replace(/\[\{/, '{').replace(/\}\]/, '}')
console.log(result)
fs.writeFile('result.json', result, 'utf8', function (err) {
    if (err) return console.log(err);
});